package Thread;

/**
 * @author liyang
 * @version 1.0
 * @package Thread
 * @file SleepDemo2.java
 * @description
 * @time 2024-04-07 20:55
 */
public class SleepDemo2 {
    public static void main(String[] args) {
        Thread lin = new Thread(){
          @Override
          public void run(){
              System.out.println("睡");
              try {
                  Thread.sleep(5000);
                  System.out.println("醒了");
              } catch (InterruptedException e) {
                  System.out.println("被强制唤醒了");
              }


          }
        };

        Thread huang = new Thread(){
            @Override
            public void run(){
                for (int i=0;i<3;i++) {
                    System.out.println("2-1");
                    System.out.println("2-2");

                }
            }
        };

        lin.start();
        huang.start();
        //之所以要抛出sleep的原因：用中断吵醒睡眠的阻塞
        //lin.interrupt();

    }
}
